# Name: GenerateIconPyCode.py #
# 
# Author: Waters #
# Creation Date: 2021.11.17 #
# Version: v0.0.1 #
# 

import os
import base64

def CreateCodeFromIcon(szIconsDir):
	lIconsNames = os.listdir(szIconsDir)
	lszIconsCode = []
	if(lIconsNames):
		for eachName in lIconsNames:
			temp_szIconPath = szIconsDir + eachName
			with open(temp_szIconPath, 'rb') as fIcon_In:
				lszIconsCode.append('szIcon_%s = %s\n' %(os.path.splitext(eachName)[0], base64.b64encode(fIcon_In.read())))
	else:
		pass
	if(lszIconsCode):
		with open('Icon.py', 'w') as fIcon_Out:
			fIcon_Out.writelines(lszIconsCode)
	else:
		pass
	return 0


if __name__ == '__main__':
	szIconsDir = './Icons/'
	CreateCodeFromIcon(szIconsDir)